export default {
  namespaced: true,
  state: {},
  getters: {
    formRules: (state, getters, rootState) => {
      return {
        //录单校验
        nameRules: [{ required: true, message: '请输入姓名' }],
        cardTypeRules: [{ required: true, message: '请选择证件类型' }],
        cardNoeRules: [
          { required: true, message: '请输入证件号码' },
          {
            validator: value => {
              // let reg = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[X])$)$/
              if (value.length == 15) {
                return true
              } else if (value.length == 18) {
                return true
              } else {
                return false
              }
            },
            message: '请输入正确的身份证号'
          }
        ],
        mobileRules: [
          { required: true, message: '请输入手机号' },
          {
            validator: value => {
              let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
              value = value.trim()
              if (value && (value.length !== 11 || !reg.test(value))) {
                return false
              }
            },
            message: '请输入正确的手机号'
          }
        ],
        areaeRules: [
          {
            validator: () => {
              let value = rootState.product.appPolicyHolderInfo.area
              if (!value.length) return false
              return true
            },
            message: '请选择省市区'
          }
        ],
        streetRules: [{ required: true, message: '请输入详细地区' }],
        emailRules: [
          {
            validator: value => {
              const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
              if (
                value == '' ||
                value == undefined ||
                value == null ||
                !reg.test(value)
              ) {
                return false
              }
            },
            message: '请输入正确的电子邮箱'
          }
        ],
        relationTypeRules: [
          { required: true, message: '请选择与投保人的关系' }
        ],
        chnNameRules: [{ required: true, message: '请输入姓名' }],
        beCardTypeRules: [{ required: true, message: '请选择证件类型' }],
        beCardNoRules: [{ required: true, message: '请输入证件号码' }],

        sexTypeRules: [{ required: true, message: '请选择性别' }],
        birthdayTypeRules: [{ required: true, message: '请输入出生日期' }],
        idEndDateTypeRules: [
          { required: true, message: '请输入证件有效期止期' }
        ],
        nationRules: [],
        marriageTypeRules: [],
        heightRules: [],
        weightRules: [],
        peopleTypeRules: [{ required: true, message: '请选择受益人类型' }],
        beneficialOrder: [{ required: true, message: '请输入受益人顺序' }],
        beneficialRatio: [{ required: true, message: '请输入受益人比例' }],
        relationTypeRules2: [{ required: true, message: '请选择与被保人关系' }],
        dateTypeRules: [{ required: true, message: '请输入日期' }],
        carboradTypeRules: [{ required: true, message: '请选择车船税类型' }],
        moneyRules: [{ required: true, message: '请输入金额' }],
        noEmptyRules: [{ required: true, message: '不能为空' }],
        insuranceNoRules: [{ required: true, message: '请输入保单号' }],
        carNo: [{ required: true, message: '请输入车牌号' }],
        bankTypeRules: [{ required: true, message: '请选择开户银行' }],
        bankNoRules: [{ required: true, message: '请输入银行卡号' }],
        //新增客户的校验
        idTypeRules: [{ required: true, message: '请选择证件类型' }],
        idNoeRules: [
          { required: true, message: '请输入证件号码' },
          {
            validator: value => {
              if (value.length == 15) {
                return true
              } else if (value.length == 18) {
                return true
              } else {
                return false
              }
            },
            message: '请输入正确的身份证号'
          }
        ],
        cusEmailRules: [
          { required: false, message: '请输入电子邮箱' },
          {
            validator: value => {
              const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
              if (value && !reg.test(value)) {
                return false
              }
            },
            message: '请输入正确的电子邮箱'
          }
        ],
        // bankIdRules: [{ required: false, message: '请选择开户银行' }],
        // cardNoRules: [{ required: false, message: '请输入银行卡号' }]

        // 录单第三步配送人员
        agent: [{ required: true, message: '请选择代理人姓名' }],
        receiver: [{ required: true, message: '请输入收件人姓名' }],
        receiverMobile: [
          { required: true, message: '请输入手机号码' },
          {
            validator: value => {
              let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
              value = value.trim()
              if (value && (value.length !== 11 || !reg.test(value))) {
                return false
              }
            },
            message: '请输入正确的手机号'
          }
        ],
        reAddr: [
          {
            validator: () => {
              let value = rootState.product.info.reAddr
              if (!value.length) return false
              return true
            },
            message: '请选择省市区'
          }
        ],
        receiverAddress: [{ required: true, message: '请输入详细地区' }],
        receiverEmail: [
          {
            validator: value => {
              const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
              if (
                value == '' ||
                value == undefined ||
                value == null ||
                !reg.test(value)
              ) {
                return false
              }
            },
            message: '请输入正确的电子邮箱'
          }
        ]
      }
    }
  },
  mutations: {}
}
